<!DOCTYPE html>
<!--引入模板引擎-->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>学生列表</title>
</head>
<body>
    <form action="/students" method="get">
        姓名：<input type="text" name="name" th:value="${name!=null}?${name}">
        年级:
        <select name="gradeId">
            <option value="">--请选择--</option>
            <option th:each="grade:${grades}" th:value="${grade.gradeId}" th:text="${grade.gradeName}" th:selected="${gradeId!=null}?${gradeId==grade.gradeId}"></option>
        </select>
        <input type="submit" value="查询">
    </form>
    <a href="javascript:void(0)" th:href="@{/gotoadd}">新增学生</a>
    <table border="1" cellpadding="10" cellspacing="0">
        <tr>
            <td>编号</td>
            <td>姓名</td>
            <td>性别</td>
            <td>年级</td>
            <td>操作</td>
        </tr>
        <tr th:each="stu:${students}">
            <td th:text="${stu.id}"></td>
            <td th:text="${stu.name}"></td>
            <td th:text="${stu.sex}"></td>
            <td th:text="${stu.grade.gradeName}"></td>
            <td>
                <a href="javascript:void(0)" th:href="@{/delete/}+${stu.id}">删除</a>
                <a href="javascript:void(0)" th:href="@{/selbyid/}+${stu.id}">修改</a>
            </td>
        </tr>
    </table>
    当前第<span th:text="${pageInfo.pageNum}"></span>页/共<span th:text="${pageInfo.pages}"></span>页
    <a th:href="@{/students/}+1+(${name==null}?'':'?name='+${name})+(${gradeId==null}?'':'&gradeId='+${gradeId})">首页</a>
    <a th:href="@{/students/}+(${pageInfo.pageNum-1>0}?${pageInfo.pageNum-1}:1)+(${name==null}?'':'?name='+${name})+(${gradeId==null}?'':'&gradeId='+${gradeId})">上一页</a>
    <a th:href="@{/students/}+(${pageInfo.pageNum+1>pageInfo.pages}?${pageInfo.pages}:${pageInfo.pageNum+1})+(${name==null}?'':'?name='+${name})+(${gradeId==null}?'':'&gradeId='+${gradeId})">下一页</a>
    <a th:href="@{/students/}+${pageInfo.pages}+(${name==null}?'':'?name='+${name})+(${gradeId==null}?'':'&gradeId='+${gradeId})">尾页</a>
</body>
</html>